package cn.rocky.offer;

public class offer53 {

    public int missingNumber(int[] nums) {
        int i = 0,j = nums.length - 1;
        while(i <= j) {
            int m = (i + j) / 2;
            if (nums[m] == m) {
                i = m + 1;
            } else {
                j = m - 1;
            }
        }
        return i;
    }

    public static void main(String[] args) {
        int[] nums = new int[]{0,1,2,3,5,6};
        offer53 offer53 = new offer53();
        int missingNumber = offer53.missingNumber(nums);
        System.out.println(missingNumber);
    }
}
